package com.example.easyexcel;

import com.example.easyexcel.service.impl.AssetTargetInfoServiceAopImpl;
import jakarta.annotation.PreDestroy;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

@SpringBootApplication
@EnableAspectJAutoProxy // 启用 AspectJ 自动代理
@MapperScan({"com.example.easyexcel.dao"})
public class EasyExcelApplication {

    private final AssetTargetInfoServiceAopImpl assetTargetInfoServiceImpl;

    // 通过构造函数注入具体的实现类
    @Autowired
    public EasyExcelApplication(AssetTargetInfoServiceAopImpl assetTargetInfoServiceImpl) {
        this.assetTargetInfoServiceImpl = assetTargetInfoServiceImpl;
    }

    public static void main(String[] args) {
        SpringApplication.run(EasyExcelApplication.class, args);
    }

    @PreDestroy
    public void onShutdown() {
        // 直接调用实现类的关闭方法
        assetTargetInfoServiceImpl.shutdownExecutors();
    }
}